package com.jarvis.dubbo.stub;

import com.jarvis.dubbo.pojo.ValidationModel;
import com.jarvis.dubbo.service.IStubService;
import org.apache.commons.lang3.StringUtils;

import java.util.logging.Logger;

/**
 * TODO XXX
 *
 * @author jarvis
 * created in 2020/9/17
 */
public class StubServiceStub implements IStubService {
    Logger logger = Logger.getLogger(this.getClass().getCanonicalName());
    private final IStubService stubService;

    public StubServiceStub(IStubService stubService) {
        this.stubService = stubService;
    }

    @Override
    public String echoHello(ValidationModel model) {
        if(StringUtils.isBlank(model.getId())){
            logger.warning("id 不能为空");
            return "调用错误，id 不能为空";
        }
        if(StringUtils.isBlank(model.getName())){
            logger.warning("名字不能空");
            return "调用错误，名字不能为空";
        }
        return this.stubService.echoHello(model);
    }
}
